import 'package:flutter/material.dart';
import 'package:flutter_statusbar_manager/flutter_statusbar_manager.dart';
import 'package:net/navigator/hi_navigator.dart';
import 'package:net/page/profile.dart';
import 'package:net/page/video_detail.dart';
import 'package:net/provider/theme_provider.dart';
import 'package:hi_base/color.dart';
import 'package:net/widget/navigation_bar.dart';
import 'package:provider/provider.dart';

///修改状态栏
void changeStatusBar({
  color: Colors.white,
  StatusStyle statusStyle: StatusStyle.DARK_CONTENT,
  BuildContext context,
}) {
  // 后面新增
  if (context != null) {
    var themeProvider = Provider.of<ThemeProvider>(context, listen: false);
    // var themeProvider = context.watch<ThemeProvider>();
    // print(themeProvider);
    if (themeProvider.isDark()) {
      statusStyle = StatusStyle.LIGHT_CONTENT;
      color = HiColor.dark_bg;
    }
    var page = HiNavigator.geInstance().getCurrent()?.page;
    // fix Android切换（程序压后台然后回来的时候） profile页面状态栏变白问题
    // ---我这里设置的是白的所以不用改-这玩意可能要提到这个外面一层
    // 针对不同页面 处理不同情况
    if (page is ProfilePage) {
      color = Colors.transparent;
    } else if (page is VideoDetailPage) {
      // statusStyle = StatusStyle.LIGHT_CONTENT;
      // color = Colors.black;
    }
  }

  //沉浸式状态栏样式
  FlutterStatusbarManager.setColor(color, animated: false);
  FlutterStatusbarManager.setStyle(
    statusStyle == StatusStyle.DARK_CONTENT
        ? StatusBarStyle.DARK_CONTENT
        : StatusBarStyle.LIGHT_CONTENT,
  );
}

// 底部阴影
BoxDecoration bottomBoxShadow(BuildContext context) {
  // 适配theme
  var themeProvider = context.watch<ThemeProvider>();
  if (themeProvider.isDark()) return null;

  return BoxDecoration(
    color: Colors.white,
    boxShadow: [
      BoxShadow(
        color: Colors.grey[100],
        offset: Offset(0, 5), //xy轴便宜
        blurRadius: 5.0,
        spreadRadius: 1,
      )
    ],
  );
}
